package pers.corvey.crawler.model;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

public class MovieGenre {

	private String movieId;
	private String genreId;
	
	public MovieGenre() {}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
	}
	
	public static List<MovieGenre> createMovieGenres(Movie movie) {
		String movieId = movie.getId();
		if (movieId == null) {
			throw new IllegalArgumentException("movie的ID不能为空！");
		}
		List<MovieGenre> ret = new ArrayList<>();
		for (Genre genre : movie.getGenres()) {
			MovieGenre mg = new MovieGenre();
			mg.setMovieId(movieId);
			mg.setGenreId(genre.getId());
			ret.add(mg);
		}
		return ret;
	}
	
	public String getMovieId() {
		return movieId;
	}

	public void setMovieId(String movieId) {
		this.movieId = movieId;
	}

	public String getGenreId() {
		return genreId;
	}

	public void setGenreId(String genreId) {
		this.genreId = genreId;
	}
}
